package jiekou;

import java.util.Random;
import java.util.Scanner;

public class text {
    public static void main(String[] args) {
        SkyFighter a = new SkyFighter();
        a.name = "熊式战斗机";
        a.color = "银色";
        a.num = "80发";
        a.radius = "方圆30公里";
        bomber b = new bomber();
        b.name = "群式战斗机";
        b.color = "黑色";
        b.num = "100发";
        b.radius = "方圆28公里";
        fighter c = new fighter();
        c.name = "鹏式战斗机";
        c.color = "灰色";
        c.num = "120发";
        c.radius = "方圆35公里";
        System.out.println("请输入你要挑选的战机编号");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ji=0;
        if (n == 1) {
            System.out.println("您挑选的是" + a.name);
            ji= a.i;
        } else if (n == 2) {
            System.out.println("您挑选的是" + b.name);
            ji= a.i;
        } else if (n == 3) {
            System.out.println("您挑选的是" + c.name);
            ji= a.i;
        } else {
            System.out.println("非选择范围，请重新运行");
            System.exit(0);
        }
        System.out.println("正在为您随机对手");
        Random q = new Random();
        int w = q.nextInt(3 - 1 + 1) + 1;
        int di;
        if (w == 1) {
            System.out.println("为您挑选的是" + a.name);
            di= a.i;
        } else if (w == 2) {
            System.out.println("为您挑选的是" + b.name);
            di= a.i;
        } else {
            System.out.println("为您挑选的是" + c.name);
            di= a.i;
        }
        while (true){
        int e;
        int o;
        if (n == 3) {
            System.out.println("请挑选所释放的技能1-4");
            e = sc.nextInt();
            o=peng(c, e);
        } else if (n == 1) {
            System.out.println("请挑选所释放的技能1或2");
            e = sc.nextInt();
            o=xiong(a, e);
        } else {
            System.out.println("请挑选所释放的技能1或2");
            e = sc.nextInt();
            o=qun(b, e);
        }
        int i;
            if (w == 3) {
                Random x = new Random();
                int z = x.nextInt(4 - 1 + 1) + 1;
                i=pen(c, z);
            } else if (w == 1) {
                Random x = new Random();
                int z = x.nextInt(2 - 1 + 1) + 1;
                i=xion(a, z);
            } else {
                Random x = new Random();
                int z = x.nextInt(2 - 1 + 1) + 1;
                i=qu(b, z);
            }
            ji=zdw(o,i,ji);
            di=zdd(o,i,di);

        System.out.println("您的剩余生命值为"+ji);
        System.out.println("对方的剩余生命值为"+di);
        if(ji<=0&&di>0){
            System.out.println("很遗憾，您输了");
            break;
        }else if(di<=0&&ji>0){
            System.out.println("恭喜，您胜利了");
            break;
        }
    }
}

    public static int  qun(bomber b, int e) {
        int r = 0;
        switch (e) {
            case 1:
                b.ground();
                System.out.println("您释放1技能，免疫部分伤害");
                break;
            case 2:
                b.bomb();
                System.out.println("您释放2技能，造成25点伤害");
                r=25;
                break;
            default:
                System.out.println("超出范围请重新选择");
        }
        return r;
    }

    public static int xiong(SkyFighter a, int e) {
        int r = 0;
        switch (e) {
            case 1:
                a.rise();
                System.out.println("您释放1技能,造成25点伤害");
                r=25;
                break;
            case 2:
                a.gliding();
                System.out.println("您释放2技能免疫部分伤害");
                break;
            default:
                System.out.println("超出范围请重新选择");
        }
        return r;
    }

    public static int peng(fighter c, int e) {
        int r = 0;
        switch (e) {
            case 1:
                c.rise();
                System.out.println("您释放1技能，免疫部分伤害");
                break;
            case 2:
                c.gliding();
                System.out.println("您释放2技能，免疫部分伤害");
                break;
            case 3:
                c.ground();
                System.out.println("您释放3技能，免疫部分伤害");
                break;
            case 4:
                c.bomb();
                System.out.println("您释放4技能,造成25点伤害");
                r=25;
                break;
            default:
                System.out.println("超出范围请重新选择");
        }
        return r;
    }
    public static int  qu(bomber b, int e) {
        int t=0;
        switch (e) {
            case 1:
                b.ground();
                System.out.println("对方释放1技能，免疫部分伤害");
                break;
            case 2:
                b.bomb();
                System.out.println("对方释放2技能，造成25点伤害");
                t = 25;
                break;
            default:
                System.out.println("超出范围请重新选择");
        }
        return t;
    }

    public static int xion(SkyFighter a, int e) {
        int t=0;
        switch (e) {
            case 1:
                a.rise();
                System.out.println("对方释放1技能,造成25点伤害");
                t = 25;
                break;
            case 2:
                a.gliding();
                System.out.println("对方释放2技能免疫部分伤害");
                break;
            default:
                System.out.println("超出范围请重新选择");
        }
        return t;
    }

    public static int pen(fighter c, int e) {
        int t=0;
        switch (e) {
            case 1:
                c.rise();
                System.out.println("对方释放1技能，免疫部分伤害");
                break;
            case 2:
                c.gliding();
                System.out.println("对方释放2技能，免疫部分伤害");
                break;
            case 3:
                c.ground();
                System.out.println("对方释放3技能，免疫部分伤害");
                break;
            case 4:
                c.bomb();
                System.out.println("对方释放4技能,造成25点伤害");
                t = 25;
                break;
            default:
                System.out.println("超出范围请重新选择");
        }
        return t;
    }
    public static int zdw(int r,int t,int ji){
        if (r==0&&t==0){
            ji = ji;
        }else if (t == 0){
            ji = ji;
        }else if(r == 0){
            ji = ji - t + 5;
        }else {
            ji = ji - t;
        }
        return ji;
    }
    public static int zdd(int r,int t,int di){
        if (r==0&&t==0){
            di = di;
        }else if(r == 0){
            di = di;
        }else if (t == 0){
            di = di - r + 5;
        }else{
            di=di-r;
        }
        return di;
    }
}
